package simple.framework.util;

import java.util.*;
import simple.framework.util.dbc.*;

public class db {

    public static dbc newInstance(conf argConf) {
        dbc tDbc = null;
        conf tConf = argConf;
        tDbc = newInstance(tConf, tConf.dbtype, tConf.connStr);
        return tDbc;
    }

    public static dbc newInstance(conf argConf, String key) {
        dbc tDbc = null;
        conf tConf = argConf;
        if (tConf.connMap == null || tConf.connMap.get(key) == null) {
        }
        return tDbc;
    }

    private static dbc newInstance(conf argConf, String dbtype, String connStr) {
        dbc tDbc = null;
        conf tConf = argConf;
        String tDbtype = dbtype;
        String tConnStr = connStr;
        if (cls.getNum(tDbtype, 0) == 1) {
            tDbc = new mysql();
        } else if (cls.getNum(tDbtype, 0) == 2) {
            tDbc = new sqlite();
            String tSqLiteString = cls.getLRStr(tConnStr, "sqlite:", "rightr");
            String tnSqLiteString = tConf.application.getRealPath(tSqLiteString).toString();
            tConnStr = tConnStr.replace(tSqLiteString, tnSqLiteString);
        } else if (cls.getNum(tDbtype, 0) == 11) {
            tDbc = new access();
            String tDBQString = cls.getLRStr(tConnStr, "DBQ=", "rightr");
            tDBQString = cls.getLRStr(tDBQString, "#", "leftr");
            String tnDBQString = tConf.application.getRealPath(tDBQString).toString();
            tConnStr = tConnStr.replace(tDBQString, tnDBQString);
        } else if (cls.getNum(tDbtype, 0) == 12) {
            tDbc = new sqlserver();
        } else if (cls.getNum(tDbtype, 0) == 21) {
            tDbc = new postgresql();
        }
        tDbc.setConnStr(tConnStr);
        return tDbc;
    }
//
//    public static void main(String[] args) {
//        Map a = new HashMap();
//        String[] ary = new String[2];
//        a.put("cxc", ary);
//        String[] tary = (String[]) a.get("cxc");
//        System.out.println(a.get("cxc1"));
//
//    }
}